#define _CRT_SECURE_NO_WARNINGS   
#include"string.h"
using namespace std;
void test1()
{
	string s1;
	string s2("hello wo\0rld");
	//cout << s2.c_str() << endl;
	cout << s2 << endl;
	string s3 = s2;
	s1 = s3;
	
	cin >> s1;
	cout << s1 << endl;
	for (size_t i = 0; i < s1.size(); i++)
	{
		s1[i]++;
	}
	cout <<s1<< endl;
}

void test2()
{
	lhy::string s1;
	lhy::string s2("hello world");
	cout << (s2 > s1) << endl;
	for (auto ch : s2)
	{
		cout << ch << " ";
	}
	cout << endl;
	s2.resize(9);
	cout << s2 << endl;
	cout << s2.size() << endl;

	cout << s2.capacity() << endl;
	s2.reserve(100);
	cout << s2.capacity() << endl;
	cout << s1.empty() << endl;
	cout << s2.empty() << endl;
}

void test3()
{
	
	lhy::string s1("i like study");
	s1.push_back(',');
	cout << s1 << endl;
	s1.append("cplusplus");
	cout << s1 << endl;
	s1 += "i like study";
	cout << s1 << endl;
	s1.insert(0, "it's strangle that ");
	cout << s1 << endl;
	s1.insert(3, 5, 'x');
	cout << s1 << endl;
	s1.erase(17);
	cout << s1 << endl;
	//s1.clear();
	cout <<s1<<" "<< s1.size() << endl;
	lhy::string s2("hello world");
	s1.swap(s2);
	cout << s1 <<endl<< s2;
}

void test4()
{
	lhy::string url("https://mpbeta.csdn.net/mp_blog/manage/article");
	size_t pos1 = url.find(':');
	lhy::string protocol=url.substr(0,pos1);
	cout << protocol << endl;
	size_t pos2 = url.find('/',pos1+3);
	lhy::string domain = url.substr(pos1+3, pos2 - (pos1 + 3));
	cout << domain << endl;
	lhy::string uri= url.substr(pos2+1,lhy::string::npos);
	cout << uri << endl;
}

int main()
{
	test1();
	test2();
	test3();
	test4();

	return 0;
}